<table cellpadding='0' cellspacing='0' width='100%'><tr bgcolor='#e0e0e0'><td>
Actions: [
<!--	<a href='javascript:process("add", "stale");' />add_stale</a>
		| <a href='javascript:process("add", "retired");' />add_retired</a>
-->
] URLs: [
	<a href=''>refresh</a>
]
</table>

<h2>Main</h2>
<?php
include "showTaskList.php";
echo "<p>\n";

/*
echo "<form name='task_list' method='post'>\n";
echo "<table id='$css_table_id' cellspacing='0'>\n";
echo "<caption>Tasks:</caption>\n";
echo "<tr>\n";
echo "<th>Delete\n";
echo "<th align='center'>Id\n";
//echo "<th align='center'>Date\n";
echo "<th align='center'>Task\n";
echo "<th align='center'>Pri\n";
echo "<th align='center'>State\n";
echo "<th align='center'>%\n";
echo "<th align='center'>Done\n";
echo "<th align='center'>Total\n";
echo "<th align='center'>Time\n";
//echo "<th align='center'>Action\n";

foreach($tm->tasks as $task) {
	// Calculate the percentage
	$result = $task->complete / $task->total;

	// Make something readable from 'seconds'
	$sec = $task->seconds;
	$s = floor($sec % 60);
	$m = floor($sec / 60);
	$h = floor($m / 60);

	echo "<tr>\n";
	echo "<td>"
			. "<input type='submit'"
			." onClick=\"javascript:process('del_task', 'id=". $task->id."');\""
			." value='del'/>\n";

	echo "<td align='center'>". $task->id;
//	echo "<td align='center'>". date("m/d H:m:s", $task->timestamp);
	echo "<td align='center'>". $task->todo;
	echo "<td align='center'>";
	echo "<select name='priority' onChange='javascript:process("
		. "\"priority\",\""
		. "id=". $task->id
//		."|priority=\" + document.task_list.priority.selectedIndex"
		."|priority=\" + this.selectedIndex"
		. ")'>\n";
	for($ctr = 0; $ctr <= 5; $ctr ++) {
		if($task->priority == $ctr) {
			echo "<option selected>"
				. $task->priority
				. "</option>";
		}
		else {
			echo "<option>" . $ctr . "</option>";
		}
	}
	echo "</select>\n";
	switch($task->state) {
	case 1:
		echo "<td align='center'>Active\n";
		echo "<td align='center'>". number_format(100 * $result, 2) ."%"."\n";
		echo "<td align='center'>". $task->complete ."\n";
		echo "<td align='center'>". $task->total ."\n";
		echo "<td align='center' nowrap>$h h $m m $s s\n";
		break;
	case 2:
		echo "<td align='center'>Complete\n";
		//echo "<td align='center'>100.00%\n";
		echo "<td align='center'>". number_format(100 * $result, 2) ."%"."\n";
		echo "<td align='center'>". $task->complete ."\n";
		echo "<td align='center'>". $task->total ."\n";
		echo "<td align='center' nowrap>$h h $m m $s s\n";
		break;
	}
//	echo "<td align='center'>\n";
//	echo "<a href='javascript:process(\"del_task\", \"id=". $task->id ."\");' />del</a>\n";
}
echo "</table>\n";
echo "</form>\n";
*/

echo "<table id='$css_table_id' cellspacing='0'>\n";
echo "<caption>Clients:</caption>\n";
echo "<th align='center'>Host\n";
echo "<th align='center'>IP\n";
//echo "<tr><td>";
$network->send("cmd=client_list\n");
// loop watching for the reply
if($from = $network->recv()) {
	if(strpos($from, "client_list_reply") !== false) {
		$pm->init($from, "|");
		$count = $pm->get("count");
		for($index = 0; $index < $count; $index ++) {
			$from = $network->recv();
//			echo "'$from'<br>";
			if(strpos($from, "client_list_item") !== false) {
				$pm->init($from, "|");
				echo "<tr>"
//					."<td align='center'>". gethostbyaddr($pm->get("host"))
					."<td align='center'>". ""
					."<td align='center'>". $pm->get("host")
				   	."\n";
			}
			else {
				$index --;
			}
		}
//		break;
	}
}
echo "</table>\n";
?>
